import React from "react";
import { MyContext } from "../D2UseContext";
const Grand = () => {
  return (
    <div>
      <h1>GrandComponent</h1>
      <MyContext.Consumer>
        {({ year, setYear }) => (
          <div>
            <h2>{year}</h2>
            <button onClick={() => setYear(year + 1)}>点击</button>
          </div>
        )}
      </MyContext.Consumer>
    </div>
  );
};
export default Grand;
